
import dialogForm from './edit'              //弹窗组件
import agentHttp from '@/utils/agentHttp'    //请求方法
import pagination from '@/views/pagination'  //分页组件
import {confirm} from '@/utils/confirm'      //二次确认组件
export default {
  name: 'homeCarousel',
  components:{dialogForm,pagination},
  created(){ 
      this.seachData()
  },
  data() {
    return {
      //表格字段
      tableData: [{}],

      //弹窗状态数据
      dialogSendData:{
        isAdd:"",
        dialogFormVisible:"",
        id:""
      },
      searchForm:{
         endDate:"",
         startDate:""
      },
      startDateOpt: {
        disabledDate(time) {
          return time.getTime() > Date.now() 
        }
      },
      endDateOpt:{
          disabledDate:(time)=>{
            return  time.getTime()< new Date(this.searchForm.startDate).getTime();
          }
      },
      resetFormStatus:false
    }
  },
  methods: {
    seachData(){
      if(!this.resetFormStatus){
        var params=this.searchForm||{};
        params.page=this.tableData.page||1;
        params.rows=this.tableData.rows||10;
        agentHttp.post('adminApi/admin/carousel/queryAllByEntity',params ).then((data)=>{
              this.tableData = data
        })
      }
    },
    /*表格操作按钮*/
   
    //新增、编辑
    handleSee(index, row){
      row?this.dialogSendData.id=row.id:this.dialogSendData.id="";
      this.dialogSendData.isAdd=false;
      this.dialogSendData.dialogFormVisible=true;
    },
    resetSearchForm(formName) {
        this.resetFormStatus=true;
        this.tableData.page=1;
        this.tableData.rows=10;
        this.$refs[formName].resetFields();
        this.$nextTick(_ =>{
          this.resetFormStatus=false;
          this.seachData();
        })
    }
  }
}